package cn.eleven.controller;

import cn.eleven.common.Result;
import cn.eleven.entity.Job;
import cn.eleven.service.JobService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.List;

@RestController
@RequestMapping("/jobs")
@CrossOrigin // 允许跨域
public class JobController {

    @Autowired
    private JobService jobService;

    /**
     * 查询所有职位信息
     * @return 所有职位列表
     */
    @GetMapping("/all")
    public List<Job> getAllJobs() {
        return jobService.getAllJobs();
    }

    @PostMapping("/post")
    public Result post(@RequestBody Job job){
        jobService.save(job);
        return Result.success();
    }
}
